/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.annuaireComp.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author MiniK
 */
@Entity
@Table(name = "competence_personnel")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CompetencePersonnel.findAll", query = "SELECT c FROM CompetencePersonnel c"),
    @NamedQuery(name = "CompetencePersonnel.findByIdcompetence", query = "SELECT c FROM CompetencePersonnel c WHERE c.competencePersonnelPK.idcompetence = :idcompetence"),
    @NamedQuery(name = "CompetencePersonnel.findByIdpersonnel", query = "SELECT c FROM CompetencePersonnel c WHERE c.competencePersonnelPK.idpersonnel = :idpersonnel"),
    @NamedQuery(name = "CompetencePersonnel.findByAnneesXp", query = "SELECT c FROM CompetencePersonnel c WHERE c.anneesXp = :anneesXp")})
public class CompetencePersonnel implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CompetencePersonnelPK competencePersonnelPK;
    @Column(name = "annees_xp")
    private Integer anneesXp;
    @Lob
    @Size(max = 65535)
    @Column(name = "commentaire")
    private String commentaire;
    @JoinColumn(name = "idpersonnel", referencedColumnName = "idpersonnel", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Personnel personnel;
    @JoinColumn(name = "idcompetence", referencedColumnName = "idcompetence", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Competence competence;

    public CompetencePersonnel() {
    }

    public CompetencePersonnel(CompetencePersonnelPK competencePersonnelPK) {
        this.competencePersonnelPK = competencePersonnelPK;
    }

    public CompetencePersonnel(int idcompetence, int idpersonnel) {
        this.competencePersonnelPK = new CompetencePersonnelPK(idcompetence, idpersonnel);
    }

    public CompetencePersonnelPK getCompetencePersonnelPK() {
        return competencePersonnelPK;
    }

    public void setCompetencePersonnelPK(CompetencePersonnelPK competencePersonnelPK) {
        this.competencePersonnelPK = competencePersonnelPK;
    }

    public Integer getAnneesXp() {
        return anneesXp;
    }

    public void setAnneesXp(Integer anneesXp) {
        this.anneesXp = anneesXp;
    }

    public String getCommentaire() {
        return commentaire;
    }

    public void setCommentaire(String commentaire) {
        this.commentaire = commentaire;
    }

    public Personnel getPersonnel() {
        return personnel;
    }

    public void setPersonnel(Personnel personnel) {
        this.personnel = personnel;
    }

    public Competence getCompetence() {
        return competence;
    }

    public void setCompetence(Competence competence) {
        this.competence = competence;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (competencePersonnelPK != null ? competencePersonnelPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompetencePersonnel)) {
            return false;
        }
        CompetencePersonnel other = (CompetencePersonnel) object;
        if ((this.competencePersonnelPK == null && other.competencePersonnelPK != null) || (this.competencePersonnelPK != null && !this.competencePersonnelPK.equals(other.competencePersonnelPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.annuaireComp.entities.CompetencePersonnel[ competencePersonnelPK=" + competencePersonnelPK + " ]";
    }
    
}
